<template>
  <div class="app-container">
    <div class="query">
      <div>
        <el-button size="mini" type="primary" icon="el-icon-plus" circle @click=";form = {};dialogVisible = true ;editPassword = true "/>
      </div>
      <div>
        <el-button size="mini" icon="el-icon-refresh" circle @click="initList"/>
      </div>
    </div>
    <el-table :data="list" border fit highlight-current-row>
      <el-table-column align="center" label="#" width="95">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="登陆账号" width="200">
        <template slot-scope="scope">
          {{ scope.row.username }}
        </template>
      </el-table-column>

      <el-table-column align="center" label="昵称" width="180">
        <template slot-scope="scope">
          {{ scope.row.nickname }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="手机号" width="210">
        <template slot-scope="scope">
          {{ scope.row.phone }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="状态" width="100">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.state == 1" type="success">正常</el-tag>
          <el-tag v-else type="danger">禁用</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" label="创建时间" width="200">
        <template slot-scope="scope">
          {{ scope.row.created | parseTime }}
        </template>
      </el-table-column>

      <el-table-column align="center" label="管理" width="100">
        <template slot-scope="scope">
          <el-button  size="mini" type="primary" icon="el-icon-edit" circle  />
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      query: {page: 1, size: 20, total: 0}
    }
  },
  created() {
    this.initList()
  },
  methods: {
    initList() {
      this.$api.get('/api/user', this.query).then((res) => {
        this.list = res.data
        this.query.total = res.total
      })
    }

  }
}
</script>

<style></style>
